package com.fengplus.demo.controller;

import com.fengplus.demo.entity.AppProduct;
import com.fengplus.demo.entity.CommonResult;
import com.fengplus.demo.service.ProductService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @DubboReference(version = "${demo.service.version}")
    private ProductService productService;

    @GetMapping("/{id}")
    public CommonResult detail(@PathVariable Long id) {
        AppProduct product = productService.findOne(id);
        if(product != null){
            return new CommonResult<>(200, "查询成功", product);
        }else{
            return new CommonResult<>(400, "信息不存在");
        }
    }

}
